package logic

import (
	"context"

	"message/internal/svc"
	"message/pb/message"

	"github.com/zeromicro/go-zero/core/logx"
)

type UpdateReadStatusLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewUpdateReadStatusLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UpdateReadStatusLogic {
	return &UpdateReadStatusLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

// UpdateReadStatus 阅读消息
func (l *UpdateReadStatusLogic) UpdateReadStatus(in *message.UpdateReadRequest) (*message.Empty, error) {
	err := l.svcCtx.MessageAggregationModel.ReadMessage(l.ctx, in.ReceiverType, in.ReceiverId, in.UserId, in.Status)
	if err != nil {
		return nil, err
	}
	return &message.Empty{}, nil
}
